<template>
  <div class="page-operate">
    <!-- 位置模块 -->
    <HeadTop></HeadTop>
    <div class="page-head">
      <span class="operate-text">{{title}}</span>
      <div class="operate-box">
        <button @click="back()">关闭</button>
      </div>
    </div>
    <div class="content-area">
      <div class="warn-detail">
        <div class="tab-content">
          <div class="content1 detail-content">
            <table border="1" bordercolor='#EEE'>
              <tr>
                <td>注册代码</td>
                <td colspan="4" v-text="fault.elCode">HGGF9888</td>
                <td>电梯类型</td>
                <td colspan="4" v-text="fault.elTypeName">厢式电梯</td>
              </tr>
              <tr>
                <td>安装地址</td>
                <td colspan="4" v-text="fault.elAddress">浙江省杭州市</td>
                <td>维保单位</td>
                <td colspan="4" v-text="fault.elMaintaimName">雪米科技</td>
              </tr>
              <tr>
                <td>故障上报时间</td>
                <td colspan="4" v-text="fault.createDate">2018-4-4</td>
                <td>维修责任人</td>
                <td colspan="4" v-text="fault.maintainUserName">2018-4-15</td>
              </tr>
              <tr>
                <td>故障来源</td>
                <td colspan="4" v-text="fault.troubleFrom">2018-5-12</td>
                <td>状态</td>
                <td colspan="4" v-text="fault.aduitStatus">已维修</td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss" type="text/scss">
  @import '../../../../style/entry/components/pageChildCommon';
  @import '../../../../style/entry/components/tabDetail';
</style>
<script>
  import moment from 'moment'  // 时间格式转化
  import com from '../../../../js/common' //

  import HeadTop from "../../../../components/head-top/head-top"
  import {getFaultDetail} from '@/api/getData'

  export default {
    name: 'warnDetail',
    components: {
      HeadTop
    },
    data() {
      return {
        title: '查看详情',
        curId: 0,
        fault: {
          elCode: '',           // 注册代码
          elTypeName: '',       // 电梯类型
          elAddress: '',        // 安装地址
          elMaintaimName: '',   // 维保单位
          createDate: '',       // 故障上报时间
          maintainUserName: '', // 维修责任人
          troubleFrom: '',      // 故障来源
          aduitStatus: ''       // 状态
        }
      }
    },
    created() {
      // 获取地址栏地址
      let uid = this.$route.query.id
      this.curId = uid
      this.getDetailData() // 获取详情信息
    },
    mounted() {

    },
    methods: {
      getDetailData() { // 获取详情信息
        let self = this
        getFaultDetail({
          id: this.curId
        }).then(function (data) {
          // 获取到的后台数据
          const curData = data.data.data
          curData.createDate = moment.unix(curData.createDate / 1000).format('YYYY-MM-DD HH:mm:ss')   // 时间
          const statusObj = {'1': '未受理', '2': '已受理', '3': '需要维修', '4': '不需要维修'}
          curData.aduitStatus = statusObj[curData.aduitStatus]                                       // 状态
          self.fault = curData                                                                        // 最后赋值

        }).catch((data) => {
          this.$message.error(data.data.message)
        })
      },
      // 返回上一级
      back() {
        this.$router.go(-1);
      },
    }
  }
</script>
